package chapter06;

/**
 * @author chisheng
 * @since 2021-11-11
 */
public class ThreadGroupCreator {

    public static void main(String[] args) {
        // 当前线程的线程组
        ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup();
        // 定义一个新的线程组
        ThreadGroup myThreadGroup = new ThreadGroup("myThreadGroup");

        // 判断自定义创建的线程组的父线程组与当前线程组的关系
        System.out.println("myThreadGroup.getParent() == currentThreadGroup: " + (myThreadGroup.getParent() == currentThreadGroup));
        // myThreadGroup.getParent() == currentThreadGroup: true

        // 定义一个新的另一个线程组
        ThreadGroup myAnotherThreadGroup = new ThreadGroup(myThreadGroup, "myAnotherThreadGroup");
        // 判断 myAnotherThreadGroup 线程组的父线程组与 myThreadGroup 的关系
        System.out.println("myAnotherThreadGroup.getParent() == myThreadGroup: " + (myAnotherThreadGroup.getParent() == myThreadGroup));
        // myAnotherThreadGroup.getParent() == myThreadGroup: true
    }

}
